package top.lingkang.authoritypro.data.dto;

import lombok.Data;

import java.io.Serializable;

/**
 * @author lingkang
 * Created by 2021/12/14
 */
@Data
public class ResponseResult<T> implements Serializable {
    private int code;
    private String msg;
    private T data;

    public ResponseResult<T> ResponseResult() {
        return this;
    }

    public ResponseResult<T> ResponseResult(String msg) {
        this.msg = msg;
        return this;
    }

    public ResponseResult<T> ResponseResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
        return this;
    }

    public ResponseResult<T> ResponseResult(int code, T data) {
        this.code = code;
        msg="操作成功";
        this.data = data;
        return this;
    }

    public ResponseResult<T> ResponseResult(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        return this;
    }

    public ResponseResult<T> success() {
        code = 0;
        msg="操作成功";
        return this;
    }

    public ResponseResult<T> success(String msg) {
        code = 0;
        this.msg = msg;
        return this;
    }

    public ResponseResult<T> success(T data) {
        code = 0;
        msg="操作成功";
        this.data = data;
        return this;
    }

    public ResponseResult<T> success(String msg, T data) {
        code = 0;
        this.msg = msg;
        this.data = data;
        return this;
    }

    public ResponseResult<T> fail() {
        code = 1;
        return this;
    }

    public ResponseResult<T> fail(String msg) {
        code = 1;
        this.msg = msg;
        this.data = data;
        return this;
    }

    public ResponseResult<T> fail(String msg, T data) {
        code = 1;
        this.msg = msg;
        this.data = data;
        return this;
    }

    public ResponseResult<T> fail(int code, T data) {
        this.code = code;
        this.data = data;
        return this;
    }

    public ResponseResult<T> fail(int code, String msg) {
        this.code = code;
        this.msg = msg;
        return this;
    }

    public ResponseResult<T> fail(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        return this;
    }
}
